<%@page import="java.awt.Font"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ page import="org.jfree.data.general.DefaultPieDataset"%>
<%@ page import="org.jfree.chart.JFreeChart"%>
<%@ page import="org.jfree.chart.plot.PiePlot"%>
<%@ page import="org.jfree.chart.ChartRenderingInfo"%>
<%@ page import="org.jfree.chart.servlet.ServletUtilities"%>
<%@ page import="org.jfree.chart.urls.StandardPieURLGenerator"%>
<%@ page import="org.jfree.chart.entity.StandardEntityCollection"%>
<%@ page import="org.jfree.chart.ChartFactory"%>
<%@ page import="org.jfree.chart.ChartUtilities"%>
<%@ page import="org.jfree.data.general.PieDataset"%>
<%@ page import="org.jfree.data.category.DefaultCategoryDataset"%>
<%@ page import="org.jfree.chart.plot.PlotOrientation"%>
<%@ page import="org.jfree.chart.plot.CategoryPlot" %>
<%@ page import="java.io.*"%>
<%
 DefaultCategoryDataset dataset = new DefaultCategoryDataset();
 
 dataset.addValue(5.0, "2005", "1월"); 
 dataset.addValue(16.0, "2005", "2월"); 
 dataset.addValue(15.0, "2005", "3월"); 
 dataset.addValue(14.0, "2005", "4월");
 dataset.addValue(30.0, "2005", "5월"); 
 dataset.addValue(15.0, "2005", "6월");  
 dataset.addValue(18.0, "2005", "7월");   
 
 dataset.addValue(7.0, "2006", "1월"); 
 dataset.addValue(19.0, "2006", "2월"); 
 dataset.addValue(9.0, "2006", "3월"); 
 dataset.addValue(5.0, "2006", "4월"); 
 dataset.addValue(15.0, "2006", "5월");
 dataset.addValue(22.0, "2006", "6월"); 
 dataset.addValue(19.0, "2006", "7월"); 
 
 dataset.addValue(1.0, "2007", "1월"); 
 dataset.addValue(2.0, "2007", "2월"); 
 dataset.addValue(3.0, "2007", "3월"); 
 dataset.addValue(4.0, "2007", "4월"); 
 dataset.addValue(5.0, "2007", "5월");
 dataset.addValue(6.0, "2007", "6월"); 
 dataset.addValue(7.0, "2007", "7월"); 
 
 JFreeChart chart = ChartFactory.createBarChart("Bar Chart","월", "대여량", dataset, PlotOrientation.VERTICAL, true, true, false);
 
 chart.setBackgroundPaint(java.awt.Color.white);
 chart.setTitle("월별 DVD 대여량");
 //제목
 chart.getTitle().setFont(new Font("돋움",Font.BOLD,20));
 //범례
 chart.getLegend().setItemFont(new Font("돋움",Font.PLAIN,10));
  
 CategoryPlot plot = chart.getCategoryPlot();
 Font font = plot.getDomainAxis().getLabelFont();
 //x축 라벨
 plot.getDomainAxis().setLabelFont(new Font("돋움",font.getStyle(),font.getSize()));
 //x축 도메인
 plot.getDomainAxis().setTickLabelFont(new Font("돋움",font.getStyle(),10));
 
 font = plot.getRangeAxis().getLabelFont();
 //Y축 라벨
 plot.getRangeAxis().setLabelFont(new Font("돋움",font.getStyle(),font.getSize()));
 //Y축 범위
 plot.getRangeAxis().setTickLabelFont(new Font("돋움",font.getStyle(),10));
 
 
 ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
 String fileName = "C:\\MES\\apache-tomcat-6.0.33\\webapps\\testcahr\\img\\" + "K0001.png";
 ChartUtilities.saveChartAsPNG(new File(fileName),chart,600,300,info);
%>
<img src="img/K0001.png"/>
<br><br>
<%
try {
 DefaultPieDataset dataset2 = new DefaultPieDataset();
 
 dataset2.setValue("1월", 5); 
 dataset2.setValue("2월", 16); 
 dataset2.setValue("3월", 15); 
 dataset2.setValue("4월", 14);
 dataset2.setValue("5월", 30); 
 dataset2.setValue("6월", 15);  
 
 JFreeChart chart2 = ChartFactory.createPieChart("Pie Chart", dataset2, true, true, false);
 
 chart2.setBackgroundPaint(java.awt.Color.white);
 chart2.setTitle("월별 DVD 대여량");

 
 ChartRenderingInfo info2 = new ChartRenderingInfo(new StandardEntityCollection());
 String fileName2 = "C:\\MES\\apache-tomcat-6.0.33\\webapps\\testcahr\\img\\" + "K0002.png";
 ChartUtilities.saveChartAsPNG(new File(fileName2),chart2,600,300,info2);
} catch (Exception e) {
 
 System.out.println("error!!"); 
}
%>
<img src="img/K0002.png"/>
</body>
</html>